package com.huilai.platform.country_platform.repository;

import com.huilai.platform.country_platform.model.ChatLink;
import com.huilai.platform.country_platform.model.FeedbackBe;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import javax.transaction.Transactional;

/**
 * 作者：洪霓
 * 日期：2023/3/27
 * 注释：
 */
public interface ChatLinkReposity extends JpaRepository<ChatLink, Integer>, JpaSpecificationExecutor<ChatLink> {

    ChatLink findChatLinkByFromIdAndToId(Integer fromId, Integer toId);

    @Modifying(clearAutomatically = true)
    @Transactional
    @Query(value = "insert into chat_link(from_id, to_id)" +
            "values(:#{#chatLink.fromId},:#{#chatLink.toId})", nativeQuery = true)
    Integer addChatLink(ChatLink chatLink);

}
